import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        Solution solution = new Solution();
        System.out.println(solution.smallestNumber(n));
    }
}

class Solution {
    public int smallestNumber(int n) {
        double res = 0;
        int count = 0;
        while(n != 0){
            n /= 2;
            res += Math.pow(2,count);
            count++;
        }
        return (int)res;
    }
}

